package cn.tedu.charging.device.controller;

import cn.tedu.charging.common.JsonResult;
import cn.tedu.charging.device.pojo.vo.StationInfoVO;
import cn.tedu.charging.device.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: goodman
 * @Date: 2025/4/24 20:52
 */
@Slf4j
@RestController
@RequestMapping("/device")
@Api(tags = "设备服务")
public class DeviceController {
    @GetMapping("/hello")
    @ApiOperation("测试接口")
    public String hello(){
        log.debug("DeviceController.hello()");
        return "hello";
    }

    @Autowired
    private DeviceService deviceService;

    @ApiOperation("附近的充电站")
    @GetMapping("/station/near")
    public JsonResult<List<StationInfoVO>> nearStation(Double longitude, Double latitude, Double radius){
        log.debug("附近充电站入参:经度:{},维度:{},范围:{}",longitude,latitude,radius);
        List<StationInfoVO> stationInfoVOs = deviceService.nearStation(longitude,latitude,radius);
        JsonResult result = JsonResult.ok(stationInfoVOs);
        log.debug("附近充电站入参:经度:{},维度:{},范围:{},出参:{}",longitude,latitude,radius,stationInfoVOs);
        return result;
    }

}
